package com.example.moblie2021606170hsy0401;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    ImageView getIvMainLight ;
    Button btnLighton,btnLightoff;

    private TextView tvMainTitle;
    private ImageView ivMainLight;
    private Button btnMainLighton;
    private Button btnMainLightoff;
    private Button btnMainFan;

    private  boolean fanStatus=false;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();


            btnMainFan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if ((fanStatus)) {
                    ivMainLight.setImageResource(R.drawable.fan_on);
                    fanStatus = false;
                }else {
                    ivMainLight.setImageResource(R.drawable.fan_off);
                    fanStatus = true;
                }
            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        ivMainLight = (ImageView) findViewById(R.id.iv_main_light);
        btnMainLighton = (Button) findViewById(R.id.btn_main_lighton);
        btnMainLightoff = (Button) findViewById(R.id.btn_main_lightoff);
        btnMainFan = (Button) findViewById(R.id.btn_main_fan);
    }
}